/**
 * 
 */
package org.phowo.organizer;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.PageLayout;
import org.eclipse.ui.internal.layout.LayoutUtil;
import org.eclipse.ui.navigator.CommonNavigator;

/**
 * @author FranLero
 *
 */
public class ShowOrganizer extends AbstractHandler implements IHandler {

	public final String VIEW_ID = "org.phowo.organizer";
	
	/* (non-Javadoc)
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
	 */
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		// Get the view		
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
		String defaultPerspective = window.getWorkbench().getPerspectiveRegistry().getDefaultPerspective();
		
		IWorkbenchPage page = window.getActivePage();		
		try {
			page.showView(VIEW_ID);
		} catch (PartInitException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}

}
